package servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import domein.Begeleider;
import IO.*;

@WebServlet(name="ToonBegeleiderGegevensSevlet", urlPatterns="/ToonBegeleiderGegevens.do")
public class ToonBegeleiderGegevensServlet extends HttpServlet   {
	private static final long serialVersionUID = 1L;
 
	/**
	 * @see HttpServlet#HttpServlet()
	 */

	public ToonBegeleiderGegevensServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse response) 
			throws ServletException, IOException {
		DatabaseIO d = new DatabaseIO();
		String emailBegeleider = req.getParameter("begeleider");
			for (Begeleider b : d.listBegeleiders()) {
				if(b.getEmail().equals(emailBegeleider)){
					req.getSession().setAttribute("begeleider", b);
				}
			}
		response.sendRedirect("Gegevens_begeleider.jsp");
		d.sluitDbVerbinding();
		}
	}

